package net.vinant.idp4java;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.openid4java.server.ServerManager;

import net.vinant.idp4java.base.BaseServiceProxy;
import net.vinant.idp4java.openid4javaImpl.SimpleServiceProxy;

/**
 * Servlet implementation class SimpleServer
 */
public class EndpointServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
      
	SimpleServiceProxy _serviceProxy = null;
	

    @Override
    public void init(ServletConfig config) throws ServletException {
    	super.init(config);
    	_serviceProxy = new SimpleServiceProxy(new ServerManager());
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		_serviceProxy.getProtocolImplementation().handle(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	    //BaseServiceProxy serviceProxy = new SimpleServiceProxy();
		_serviceProxy.getProtocolImplementation().handle(request, response);
	}

}
